<template>
	<view class="container">
		<view v-if="curData.vouchers.length > 0">
			<image 
				v-for="(path,index) in curData.vouchers" :key="index"
				class="vouchers-img u-margin-bottom-10" 
				:src="path"
				@click="previewImageHandle(curData.vouchers)"
			>
			</image>
		</view>
		<view v-else>
			<empty-data tipText="待结算"></empty-data>
		</view>
		<view v-if="type == 'expend'" style="font-weight: bold;" class="u-margin-top-40 white-bg z-b-r u-padding-20 z-font-lg">
			<view class="expend-item">
				工人食宿费：{{ curData.worker_cost | $_formattingMoney }}
			</view>
			<view class="expend-item">
				钻机运费：{{ curData.drill_freight | $_formattingMoney }}
			</view>
			<view class="expend-item">
				燃油费：{{ curData.fuel_oil | $_formattingMoney }}
			</view>
			<view class="expend-item">
				配件费用：{{ curData.parts_cost | $_formattingMoney }}
			</view>
			<view class="expend-item">
				付款方：{{ curData.revenue_company }}
			</view>
			<view class="expend-item">
				付款方式：{{ curData.revenue_type }}
			</view>
			<view class="expend-item">
				日期：{{ curData.date }}
			</view>
		</view>
		
		<view v-if="type == 'income'" style="font-weight: bold;" class="u-margin-top-40 white-bg z-b-r u-padding-20 z-font-lg">
			<view class="expend-item">
				收入金额：{{ curData.income | $_formattingMoney }}
			</view>
			<view class="expend-item">
				付款方：{{ curData.revenue_company }}
			</view>
			<view class="expend-item">
				付款方式：{{ curData.revenue_type }}
			</view>
			<view class="expend-item">
				日期：{{ curData.date }}
			</view>
		</view>
		<bottom-bar v-if="curData.revenue_type == '待结算'">
			<u-button :disabled="disabledBtn" type="primary" @click="uploadBill">完成结算，上传票据</u-button>
		</bottom-bar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				curData:{},
				type:"",
				disabledBtn:false
			}
		},
		onLoad(params) {
			this.type = params.type
			this.curData = JSON.parse(decodeURIComponent(params.data));
		},
		methods: {
			previewImageHandle(paths){
				uni.previewImage({
				     urls: paths
				})
			},
			uploadBill(){
				uni.navigateTo({
					url: `../add-income/add-income?d=${encodeURIComponent(JSON.stringify(this.curData))}`
				});
			}
		}
	}
</script>

<style scoped>
	.vouchers-img{
		border-radius: 20rpx;
		width: 100%;
		height: 220rpx;
	}
	.expend-item{
		line-height: 60rpx;
	}
</style>
